<!DOCTYPE html>
<html lang="en">
<#include "../common/scripts.html">
<#include "../common/scripts_add.html">
<body>
<div class="page-content">
    <form action="" method="post" id="passwordeditForm" class="form-horizontal">
        <table class="table-main" style="width: 80% !important; margin:10px 10%;">
            <tr>
            <td><span class="required-flag">*</span><span>原密码</span></td>
            <td style="position: relative;">
                <input  type="password" class="form-control-gx" name="amcOldPassword" id="amcOldPassword" autocomplete="new-password"/>
            </td>
            </tr>
            <tr>
                <td><span class="required-flag">*</span><span>新密码</span></td>
                <td><input type="password" class="form-control-gx"  name="amcNewPassword" id="amcNewPassword" autocomplete="new-password"></td>
            </tr>
            <tr>
                <td><span class="required-flag">*</span><span>确认密码</span></td>
                <td style="position: relative;">
                    <input type="password" class="form-control-gx" name="amcConfirmPassword" id="amcConfirmPassword" autocomplete="new-password"/>
                </td>
            </tr>
        </table>
        <div class="text-center" style="width: 80%; margin:10px 10%;">
            <span class="model-btn" onclick="submit()" style="width:80px;">保存</span>
        </div>
    </form>

</div>
<script>
    function submit() {
        if(isEmpty_byJqObj($("#amcOldPassword"))){
            sys.topmsg("原密码不能为空");
            return false;
        }
        if(isEmpty_byJqObj($("#amcNewPassword"))){
            sys.topmsg("新密码不能为空");
            return false;
        }
        if(isEmpty_byJqObj($("#amcConfirmPassword"))){
            sys.topmsg("确认密码不能为空");
            return false;
        }
        if($("#amcNewPassword").val() != $("#amcConfirmPassword").val()){
            sys.topmsg("确认密码输入有误");
            return false;
        }
        $.ajax({
            url : "${ctx}/user/saveByPassword",
            type : "POST",
            datatype : "json",
            data : $('#passwordeditForm').serialize(),
            success : function(res) {
                if (res.success) {
                    sys.topmsg(res.data);
                    sys.frameDialogClose();
                    window.location.href = "/sys/logout";
                } else {
                    sys.topmsg(res.message);
                }
            },
            error : function(data) {
                js.showMessage("请求异常！","","error",1500)
            }
        });
    }
</script>
</body>
</html>
